extends StateBase


var ownerNode:Funnel


func enter(obj):
	ownerNode = obj
	
	var pos = Vector2(randf_range(ownerNode.randomMoveMinX, ownerNode.randomMoveMaxX), randf_range(ownerNode.randomMoveMinY, ownerNode.randomMoveMaxY)) 
	ownerNode.targetPos = pos
	

func exit(obj):
	pass


func run(delta, obj):
	ownerNode.position.x = lerp(ownerNode.position.x, ownerNode.targetPos.x, ownerNode.speed * delta)
	ownerNode.position.y = lerp(ownerNode.position.y, ownerNode.targetPos.y, ownerNode.speed * delta)
	
	if ownerNode.position.distance_to(ownerNode.targetPos) <= 0.001:
		ownerNode.stateMachine.removeState("Move", ownerNode)
		ownerNode.stateMachine.addState("Shoot", ownerNode)
